package com.lzh.dlykserver.mapper;

import com.lzh.dlykserver.commons.DataScope;
import com.lzh.dlykserver.entity.TTran;
import com.lzh.dlykserver.query.TransactionQuery;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author 墨墨
 * @description 针对表【t_tran(交易表)】的数据库操作Mapper
 * @createDate 2024-07-24 09:57:15
 * @Entity com.lzh.dlykserver.entity.TTran
 */
public interface TTranMapper {

    int deleteByPrimaryKey(Long id);

    int insert(TTran record);

    int insertSelective(TTran record);

    TTran selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(TTran record);

    int updateByPrimaryKey(TTran record);

    BigDecimal selectBySuccessTranAmount();

    BigDecimal selectByTotalTranAmount();

    int selectByTotalTranCount();

    int selectBySuccessTranCount();

    @Select("SELECT COUNT(*) FROM t_tran WHERE customer_id = #{customerId}")
    int countByCustomerId(Integer customerId);


    @DataScope(tableAlias = "t", tableField = "create_by")
    List<TTran> selectTranByPage(TransactionQuery tranQuery);

    TTran getTransactionById(Integer id);

    @Delete("DELETE FROM t_tran WHERE id = #{id}")
    int deleteTransaction(Integer id);

    @Delete("<script>" +
            "DELETE FROM t_tran WHERE id IN " +
            "<foreach item='item' index='index' collection='ids' open='(' separator=',' close=')'>" +
            "#{item}" +
            "</foreach>" +
            "</script>")
    int batchDeleteTransaction(List<Integer> idList);

    List<TTran> selectTransactionByExcel(@Param("idList") List<String> idList);
}
